struct listnode {
  int data;
  struct listnode * next;
};

/*  true | list(root) */
struct listnode * list_insert_head(struct listnode * root, int v)
{
  struct listnode * temp;

  temp = malloc (sizeof (struct listnode));
  temp -> data = v;
  temp -> next = root;

  return temp;
}
/* true | list(res) */


struct listnode * list_insert_tail(struct listnode * root, int v)
{
  struct listnode * temp, next, prev;
  temp = malloc (sizeof (struct listnode));
  temp -> data = v;
  temp -> next = NULL;
  if(root==NULL) {
    return temp;
  } else {
    prev=root;
    next=root->next;
    while(next!=NULL)
      {
	prev=next;
	next=next->next;
      }
    prev->next=temp;
    return root;
  }
}

